(define (cont-frac fn fd k)
    (define (iter result count)        
        (let ( 
                (n (fn k))
                (d (fd k)) 
            )
            (if (> count 1)                
                (/ n 
                    (+ d (iter result (- count 1)))
                )
                result
            )
        )
    )
    (iter (/  (fn k) (fd k)) k)    
)

(define (calc1 k)
    (cont-frac 
        (lambda (i) 1.0) 
        (lambda (i) 
            (let (
                    (r (remainder i 3))
                    (s (+ 1 (/ i 3)))
                )
                (if (= 1 r) 
                    (* 2 s)
                    1
                )
            )    
        ) 
        k
    )
)
(display (calc1 10000))
(newline)
(display (calc1 100000))
(newline)
(display (calc1 1000000))
(exit)